<?php
/**
 * 系统配置相关
 *
 * Author:李强
 * Company:上海煦鸣网络科技有限公司
 * Date:2018-01-03
 */

namespace App\Http\Controllers\Admin;

use App\Models\Config;
use Illuminate\Http\Request;

class ConfigController extends BaseController
{
    public function __construct()
    {

    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        //
        $config = Config::getAllConfig();
        $this->assign('configs', $config);
        return $this->display('user.config');
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request)
    {
        if ($request->ajax()) {
            $inputs = $request->all();
            foreach ($inputs as $key => $value) {
                Config::updateConfig($key, $value);
            }
            return $this->success('设置完成');
        }
    }

}
